<%@ page import="com.pzhu.pojo.Book" %>
<%@ page import="java.util.List" %>
<%@ page import="com.pzhu.controller.BookController" %>
<%@ page import="com.pzhu.service.impl.BookServiceImpl" %>
<%@ page import="com.pzhu.controller.impl.BookControllerImpl" %>
<%--
  Created by IntelliJ IDEA.
  User: Ice Bear
  Date: 2022/11/28
  Time: 11:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>Ice Bear Library</title>

    <%
        if (session.getAttribute("login") == null) {
            request.getRequestDispatcher("/main").forward(request, response);
            return;
        }%>
    <script src="/library/layui-v2.7.6/layui/layui.js"></script>
    <link type="text/css" rel="stylesheet" href="/library/layui-v2.7.6/layui/css/layui.css"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">Ice Bear Library</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs"><a
                    href="javascript:;">当前在线人数:${applicationScope.get("allUserCount")}</a></li>


            <li class="layui-nav-item">
                <a href="javascript:;">图书管理</a>
                <dl class="layui-nav-child">
                    <dd><a href="/library/view/jsp/book/findBook.jsp">查询</a></dd>
                    <dd><a href="/library/view/jsp/book/addBook.jsp">增加</a></dd>
                    <dd><a href="/library/view/jsp/book/updateBook.jsp">修改</a></dd>
                    <dd><a href="/library/view/jsp/book/deleteBook.jsp">删除</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="/library/show-all-books;">总览</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                         class="layui-nav-img">
                    ${sessionScope.get("Uname")}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="/library/logout">退出登录</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical">
                    </i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">图书管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/library/view/jsp/book/findBook.jsp">查询</a></dd>
                        <dd><a href="/library/view/jsp/book/addBook.jsp">增加</a></dd>
                        <dd><a href="/library/view/jsp/book/updateBook.jsp">修改</a></dd>
                        <dd><a href="/library/view/jsp/book/deleteBook.jsp">删除</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item"><a href="/library/show-all-books;">总览</a></li>
                <li class="layui-nav-item"><a href="">访问人数:${applicationScope.get("loginCount")}</a></li>
            </ul>
        </div>
    </div>
    <%
        Book book = (Book) request.getAttribute("book");
    %>
    <div class="layui-body">
        <div class="layui-card-body">
            <form class="layui-form" action="/library/update-book">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label layui-hide">ID</label>
                    <div class="layui-input-block">

                        <input type="text" name="id" id="id" required lay-verify="required" autocomplete="off"
                               class="layui-input" value="<%=book.getId() %>">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <div class="layui-form-item">
                        <label class="layui-form-label">书名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" id="name" required lay-verify="required" placeholder="请输入书名"
                                   autocomplete="off" class="layui-input" value="<%=book.getName()%>">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">作者</label>
                    <div class="layui-input-inline">
                        <input type="text" name="author" id="author" required lay-verify="required"
                               placeholder="请输入作者"
                               autocomplete="off" class="layui-input" value="<%=book.getAuthor()%>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">语言</label>
                    <div class="layui-input-inline">
                        <select name="language" id="language" lay-verify="required" lay-search>
                            <option value="<%=book.getLanguage()%>" selected="selected"><%=book.getLanguage()%>
                            </option>
                            <option value="中文">中文</option>
                            <option value="英语">英语</option>
                            <option value="德语">德语</option>
                            <option value="日语">日语</option>
                            <option value="西班牙语">西班牙语</option>
                            <option value="法语">法语</option>
                            <option value="印度语">印度语</option>
                            <option value="韩语">韩语</option>
                            <option value="泰语">泰语</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-inline">
                        <select name="classId" lay-verify="required" id="classId" lay-search>
                            <option value="<%=book.getClassId()%>" selected="selected"><%=book.getClassId()%>
                            </option>
                            <option value="马克思主义">马克思主义</option>
                            <option value="哲学">哲学</option>
                            <option value="社会科学总论">社会科学总论</option>
                            <option value="政治法律">政治法律</option>
                            <option value="军事">军事</option>
                            <option value="经济">经济</option>
                            <option value="文化">文化</option>
                            <option value="语言">语言</option>
                            <option value="文学">文学</option>
                            <option value="艺术">艺术</option>
                            <option value="历史地理">历史地理</option>
                            <option value="自然科学总论">自然科学总论</option>
                            <option value="数理科学和化学">数理科学和化学</option>
                            <option value="天文学、地球科学">天文学、地球科学</option>
                            <option value="生物科学">生物科学</option>
                            <option value="医药、卫生">医药、卫生</option>
                            <option value="农业科学">农业科学</option>
                            <option value="工业技术">工业技术</option>
                            <option value="交通运输">交通运输</option>
                            <option value="航空、航天">航空、航天</option>
                            <option value="环境科学">环境科学</option>
                            <option value="综合">综合</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">出版社</label>
                    <div class="layui-input-inline">
                        <input type="text" name="publish" id="publish" required lay-verify="required"
                               placeholder="请输入出版社名称"
                               autocomplete="off" class="layui-input" value="<%=book.getPublish() %>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">出版时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="publishDate" class="layui-input" id="publishDate"
                                   placeholder="请选择出版时间" value="<%=book.getPubDate()%>">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">价格</label>
                    <div class="layui-input-inline">
                        <input type="text" name="price" id="price" required lay-verify="required"
                               placeholder="请输入价格"
                               autocomplete="off" class="layui-input" value="<%=book.getPrice()%>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">数量</label>
                    <div class="layui-input-inline">
                        <input type="text" name="number" id="number" required lay-verify="required"
                               placeholder="请输入数量"
                               autocomplete="off" class="layui-input" value="<%=book.getNumber() %>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">ISBN</label>
                    <div class="layui-input-inline">
                        <input type="text" name="isbn" id="isbn" required lay-verify="required"
                               placeholder="请输入ISBN号"
                               autocomplete="off" class="layui-input" value="<%=book.getISBN() %>">
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">介绍</label>
                    <div class="layui-input-block">
                        <textarea name="introduction" id="introduction" placeholder="请输入图书简介内容"
                                  class="layui-textarea"><%=book.getIntroduction() %></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo" type="submit">修改</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>

        </div>
    </div>

</div>
<script>

</script>
<script>
    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element
            , layer = layui.layer
            , util = layui.util
            , $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function (othis) {
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            , menuRight: function () {
                layer.open({
                    type: 1
                    , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    , area: ['260px', '100%']
                    , offset: 'rt' //右上角
                    , anim: 5
                    , shadeClose: true
                });
            }
        });

    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#publishDate'
        });
    })
</script>

</body>
</html>
